2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../jucer_Headers.h"
27 #include "jucer_StoredSettings.h"
30 //==============================================================================
31 StoredSettings::StoredSettings()
36 StoredSettings::~StoredSettings()
40 clearSingletonInstance();
43 juce_ImplementSingleton (StoredSettings
);
46 //==============================================================================
47 PropertiesFile
& StoredSettings::getProps()
52 void StoredSettings::flush()
56 props
->setValue ("recentFiles", recentFiles
.toString());
57 props
->removeValue ("keyMappings");
59 ScopedPointer
<XmlElement
> keys (commandManager
->getKeyMappings()->createXml (true));
62 props
->setValue ("keyMappings", keys
);
64 for (int i
= 0; i
< swatchColours
.size(); ++i
)
65 props
->setValue ("swatchColour" + String (i
), colourToHex (swatchColours
[i
]));
71 PropertiesFile::Options options
;
72 options
.applicationName
= "Jucer";
73 options
.filenameSuffix
= "settings";
74 options
.osxLibrarySubFolder
= "Preferences";
76 props
= new PropertiesFile (options
);
80 recentFiles
.restoreFromString (props
->getValue ("recentFiles"));
81 recentFiles
.removeNonExistentFiles();
84 swatchColours
.clear();
86 #define COL(col) Colours::col,
88 const Colour colours
[] =
90 #include "jucer_Colours.h"
91 Colours::transparentBlack
96 for (int i
= 0; i
< numSwatchColours
; ++i
)
98 Colour
defaultCol (colours
[2 + i
]);
100 swatchColours
.add (Colour (props
->getValue ("swatchColour" + String (i
),
101 colourToHex (defaultCol
)).getHexValue32()));
105 const File
StoredSettings::getTemplatesDir() const
107 File
defaultTemplateDir (File::getSpecialLocation (File::currentExecutableFile
)
108 .getParentDirectory());
110 return File (props
->getValue ("templateDir",
111 defaultTemplateDir
.getFullPathName()));
114 void StoredSettings::setTemplatesDir (const File
& newDir
)
116 props
->setValue ("templateDir", newDir
.getFullPathName());